package net.learn2develop.GetVcb;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

public class DetailDB extends Activity{
	private DBAdapter db;
	private ListView listdata;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.detaildata);
		
		listdata = (ListView)findViewById(R.id.listdataildata);
		db = new DBAdapter(this);
		db.open();
		ArrayList<String> ArrayData = new ArrayList<String>();
		
		Cursor c = db.getFilter("country= 'USD'" , null, null, null, null);
		if(c.moveToFirst()){
			do{
				ArrayData.add(c.getString(4));
				
			}while(c.moveToNext());
		}
		
		listdata.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1
				,(String[])ArrayData.toArray(new String[0])));
		listdata.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				Intent data = new Intent();
				// TODO Auto-generated method stub
				//Toast.makeText(getBaseContext(),(String) arg0.getItemAtPosition(arg2), Toast.LENGTH_LONG).show();
				data.setData(Uri.parse((String) arg0.getItemAtPosition(arg2)));
				setResult(RESULT_OK, data);
				finish();
			}
		
		});
	}
	
}
